package by.gamedev.site.client.managed.activity;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.inject.Inject;

/**
 * Instantiates activities for the mobile app.
 */
public final class GameDevMobileActivities implements ActivityMapper {
    private final ApplicationMasterActivities listActivityBuilder;
    private Activity                          rootActivity;

    @Inject
    public GameDevMobileActivities(final ApplicationMasterActivities listActivitiesBuilder) {
        listActivityBuilder = listActivitiesBuilder;
    }

    @Override
    public Activity getActivity(final Place place) {
        final Activity rtn = listActivityBuilder.getActivity(place);
        return rtn == null ? rootActivity : rtn;
    }

    public void setRootActivity(final Activity activity) {
        rootActivity = activity;
    }
}
